﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using SL81App.Resources;
using InTheHand.ApplicationModel;
using InTheHand.Storage;
using System.Runtime.InteropServices;
using Microsoft.Phone.Info;

namespace SL81App
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            MessageBox.Show(Windows.ApplicationModel.Package.Current.Id.Version.ToString(true));

                        // Sample code to localize the ApplicationBar
            //BuildLocalizedApplicationBar();
        }

        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            InTheHand.ApplicationModel.Package p = InTheHand.ApplicationModel.Package.Current;

            string ver = typeof(Windows.System.Launcher).Assembly.GetName().Version.ToString();

            string s = Windows.ApplicationModel.Package.Current.Id.Name;
            Windows.Storage.IStorageItem itema = await Windows.Storage.ApplicationData.Current.LocalFolder.TryGetItemAsync("somefile.txt");

            Windows.Storage.IStorageItem item = await Windows.Storage.KnownFolders.CameraRoll.TryGetItemAsync("image.png");

            base.OnNavigatedTo(e);
        }

        private void ApplicationBarMenuItem_Click(object sender, EventArgs e)
        {
            InTheHand.UI.ApplicationSettings.SettingsPane.Show();
        }

        // Sample code for building a localized ApplicationBar
        //private void BuildLocalizedApplicationBar()
        //{
        //    // Set the page's ApplicationBar to a new instance of ApplicationBar.
        //    ApplicationBar = new ApplicationBar();

        //    // Create a new button and set the text value to the localized string from AppResources.
        //    ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
        //    appBarButton.Text = AppResources.AppBarButtonText;
        //    ApplicationBar.Buttons.Add(appBarButton);

        //    // Create a new menu item with the localized string from AppResources.
        //    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
        //    ApplicationBar.MenuItems.Add(appBarMenuItem);
        //}
    }
}